<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改学生信息')" />
    <th:block th:include="include :: jasny-bootstrap-css" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-teacher-edit" th:object="${editInfo}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group col-sm-5">
                <label class="col-sm-4 control-label">姓名：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">性别：</label>
                <div class="col-sm-8">
                    <div class="radio-box" style="height: 34px;" th:each="dict : ${@dict.getType('edu_sex')}">
                        <input type="radio" th:id="${'sex_' + dict.id}" name="sex" th:value="${dict.itemValue}" th:field="*{sex}">
                        <label th:for="${'sex_' + dict.id}" th:text="${dict.itemText}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group col-sm-5">
                <label class="col-sm-4 control-label">住宿：</label>
                <div class="col-sm-8" style="padding: 5px 0;">
                    <div class="radio-box" th:each="dict : ${@dict.getType('sys_yes_no')}">
                        <input type="radio" th:id="${'isAccommodation_' + dict.id}" name="isAccommodation" th:value="${dict.itemValue}" th:field="*{isAccommodation}">
                        <label th:for="${'isAccommodation_' + dict.id}" th:text="${dict.itemText}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">借读：</label>
                <div class="col-sm-8" style="padding: 5px 0;">
                    <div class="radio-box" th:each="dict : ${@dict.getType('sys_yes_no')}">
                        <input type="radio" th:id="${'isCoop_' + dict.id}" name="isCoop" th:value="${dict.itemValue}" th:field="*{isCoop}">
                        <label th:for="${'isCoop_' + dict.id}" th:text="${dict.itemText}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group col-sm-5">
                <label class="col-sm-4 control-label">入学时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="inSchoolTime" th:value="${#dates.format(editInfo.inSchoolTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                    </div>
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">出生日期：</label>
                <div class="col-sm-8" style="height: 43px;">
                    <input name="birthday" th:field="*{birthday}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">民族：</label>
                <div class="col-sm-8">
                    <input name="national" th:field="*{national}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">身份证号：</label>
                <div class="col-sm-8">
                    <input name="idNumber" th:field="*{idNumber}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">户口所在地：</label>
                <div class="col-sm-8">
                    <input name="residenceLocation" th:field="*{residenceLocation}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">家庭住址：</label>
                <div class="col-sm-8">
                    <input name="familyLocation" th:field="*{familyLocation}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">学号：</label>
                <div class="col-sm-8">
                    <input name="studentNumber" th:field="*{studentNumber}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">年级：</label>
                <div class="col-sm-8">
                    <input name="grade" th:field="*{grade}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">班级：</label>
                <div class="col-sm-8">
                    <input name="studentClass" th:field="*{studentClass}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">政治面貌：</label>
                <div class="col-sm-8">
                    <input name="politicsStatus" th:field="*{politicsStatus}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">父亲姓名：</label>
                <div class="col-sm-8">
                    <input name="fatherName" th:field="*{fatherName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">父亲联系方式：</label>
                <div class="col-sm-8">
                    <input name="父亲联系方式" th:field="*{fatherPhone}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">母亲姓名：</label>
                <div class="col-sm-8">
                    <input name="matherName" th:field="*{matherName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">母亲联系方式：</label>
                <div class="col-sm-8">
                    <input name="matherPhone" th:field="*{matherPhone}" class="form-control" type="text">
                </div>
            </div>
            <input name="photo" th:field="*{photo}" type="hidden">
            <div class="form-group" style="position:absolute; top:20px; right:25px;">
                <div class="fileinput fileinput-new" data-provides="fileinput" style="position: relative; width:140px; height:160px;">
                    <div class="fileinput-new thumbnail" style="width: 130px; height: 130px;">
                        <img th:src="(${editInfo.photo} == null) ? @{/res/img/touxiang.png} : @{'/sys/common/view/' + ${editInfo.photo}}">
                    </div>
                    <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 130px;"></div>
                    <div style="text-align: center;">
                        <span class="btn btn-white btn-file">
                            <span class="fileinput-new">选择图片</span>
                            <span class="fileinput-exists">更改</span>
                            <input type="file" id="williamYe">
                        </span>
                        <a href="#" class="btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                    </div>
                </div>
            </div>
            <div class="form-group col-sm-12" style="text-align:center">
                <label class=" control-label">竞赛奖项</label>
                <table style="width:auto;height:50px;margin-left: 30px;margin-right: 30px"
                       border="1" cellspacing="0" bordercolor="#686967">
                    <tr style="text-align: center">
                        <th style="text-align: center">序号</th>
                        <th style="text-align: center">比赛名称</th>
                        <th style="text-align: center">获奖名称</th>
                        <th style="text-align: center">获奖级别</th>
                        <th style="text-align: center">获奖时间</th>
                        <th style="text-align: center">学科</th>
                        <th style="text-align: center">证书图片</th>
                    </tr>
                    <tr style="text-align: center">
                        <td>
                            <input class="form-control" type="text" style="text-align: center" placeholder="暂无数据">
                        </td>
                        <td>
                            <input class="form-control" type="text" style="text-align: center" placeholder="暂无数据">
                        </td>
                        <td>
                            <input class="form-control" type="text" style="text-align: center" placeholder="暂无数据">
                        </td>
                        <td>
                            <input class="form-control" type="text" style="text-align: center" placeholder="暂无数据">
                        </td>
                        <td>
                            <input class="form-control" type="text" style="text-align: center" placeholder="暂无数据">
                        </td>
                        <td>
                            <input class="form-control" type="text" style="text-align: center" placeholder="暂无数据">
                        </td>
                        <td>
                            <input class="form-control" type="text" style="text-align: center" placeholder="暂无数据">
                        </td>
                    </tr>
                </table>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "education/student";
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#form-teacher-edit").validate({
            rules: {
                idNumber: {
                    required: true,
                    isIdentity:true
                }
            },
            messages: {
                idNumber: {
                    required: icon + "请输入您的身份证号",
                    isIdentity: icon + "请输入正确的身份证号"
                }
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-teacher-edit').serialize());
            }
        }

        $("input[name='inSchoolTime'],input[name='birthday']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        $('#williamYe').on('change.bs.fileinput ', function (e) {
            // 处理自己的业务
            if(this.files[0]){
                const formData = new FormData();
                formData.append('file',this.files[0]);
                $.operate.fileUpload(formData, $('input[name="photo"]'));
            }else{
                $('input[name="photo"]').val("");
            }
        });
    </script>
</body>
</html>
